/****************************************************************************
 * 2025.5 阿桑的笔记本
 ****************************************************************************/

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using UnityEditor.Experimental.Rendering;

namespace QFramework.Example
{
	public partial class BulletRoot : UIElement,IController,ICanReadModels
	{

        IWapenModel wapenModel;

		private void Awake()
		{
            ReadModels();
            wapenModel.WapenCanFireCount.RegisterWithInitValue(value =>
            {
                BulletText.text = value + "/" + wapenModel.WapenMaxBuletCount.Value.ToString();

            }).UnRegisterWhenGameObjectDestroyed(gameObject);
        }

		protected override void OnBeforeDestroy()
		{
		}

        public IArchitecture GetArchitecture()
        {
			return Global.Interface;
        }

        public void ReadModels()
        {

            GetWapenModel();

           

        }


        public void GetWapenModel()
        {
            var wapenName = DataManager.Instance. gameDatas.GunName;
            if (DataManager.Instance.gunModelDic.TryGetValue(wapenName, out var model))
            {
                //model.WapenCanFireCount.Value = model.WapenMaxBuletCount.Value;
                Debug.Log("获取到了model:"+ wapenName);
                wapenModel = model;
            }
            
        }

    }
}